﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class DragPoint : MonoBehaviour, IDragHandler
{
    public SelectBoxMng SelectBoxMng;
    public int Index;

    private RectTransform panelRectTrans;

    void Start()
    {
        this.panelRectTrans = this.transform as RectTransform;
    }

    public void OnDrag(PointerEventData eventData)
    {
        Vector3 globalMousePos;
        if (RectTransformUtility.ScreenPointToWorldPointInRectangle(this.panelRectTrans, eventData.position,
            eventData.pressEventCamera, out globalMousePos))
        {
            this.panelRectTrans.position = globalMousePos;
            this.SelectBoxMng.FlashPointsPos(this.Index);
        }
    }
}
